package com.kerberos;

import java.util.ArrayList;

import com.kerberos.R;


import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;

public class lista_paneles  extends ArrayAdapter<panel>{

    private ArrayList<panel> entradas; 
    private int R_layout_IdView; 
    private Context contexto;
	
		public lista_paneles(Context contexto, int R_layout_IdView, ArrayList<panel> entradas) {
		super(MainActivity.ctx, 0);
        this.contexto = contexto;
        this.entradas = entradas; 
        this.R_layout_IdView = R_layout_IdView; 
		}
		@Override
		public View getView(int position, View view, ViewGroup parent) {
			
	        if (view == null) {
	    	    LayoutInflater vi = (LayoutInflater) contexto.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
	                view = vi.inflate(R_layout_IdView, null); 
	                
	            }
	        
			EditText txt = (EditText) view.findViewById(R.id.nombre_panel);
			if (position<entradas.size()){
			txt.setText(entradas.get(position).titulo.getText());
			}
						
		return view;
		}
		
			
	    @Override
	    public int getCount() {
	        return entradas.size()+1;
	    }

	    @Override
	    public panel getItem(int posicion) {
	    	if (posicion> entradas.size()){
	    		panel mipanel =new panel(MainActivity.ctx);
	    		mipanel.titulo.setText("");
	    		return mipanel;
	    	}
	    	else{
	        return entradas.get(posicion);
	    	}
	    }

	    @Override
	    public long getItemId(int posicion) {
	        return posicion;
	    }


		}
